<html>
<head>

<title>Secure Login Helper - Options</title>

<script type="text/javascript">

function saveOptions() {
  var sites = {};
  for (var i = 0; i < document.forms[0].elements.length; i++) {
    if (document.forms[0].elements[i].checked) {
      sites[document.forms[0].elements[i].value] = "true";
    }
  }
  localStorage["forceSites"] = JSON.stringify(sites);
}

function restoreOptions() {
  var sites = new Array("twitter.com");
  var currentOptions = JSON.parse(localStorage["forceSites"]);
  var list = document.getElementById("sites");
  for (site in sites) {
    var item = document.createElement("input");
    item.setAttribute("type", "checkbox");
    item.setAttribute("name", "site");
    item.setAttribute("value", sites[site]);
    if (currentOptions[sites[site]] == "true") {
      item.checked = true;
    }
    item.onclick = saveOptions;
    list.appendChild(item);
    var text = document.createElement("span");
    text.innerHTML = escape(sites[site]) + "<br/>";
    list.appendChild(text);
  }
}

function initialize() {
  if (!localStorage["forceSites"]) {
    localStorage["forceSites"] = JSON.stringify({});
  }
  restoreOptions();
}

</script>

<body onload="initialize()">

<form>
<div class="optionTitle">Force SSL for these sites</div>

<div id="sites" class="options">
</div>
</form>

</body>
